alter PROCEDURE getBoProcesslist
    --工单状态
    @BoStatus NVARCHAR(255),
    @item_code NVARCHAR(255),
    @khdm VARCHAR(50),
    @team NVARCHAR(255),
    @begingmt_create DATETIME,
    @endgmt_create DATETIME,
    @PageIndex INT,
    @PageSize INT,
    @TotalCount INT OUTPUT
AS
BEGIN
    SET NOCOUNT ON;

    -- 计算分页的起始位置
    DECLARE @Offset INT = (@PageIndex - 1) * @PageSize;
--------------------------------------------------------------------------------------------
    select batch_number               工单号,
           mest.name               as MES订单类型,
           a.item_code             as item_code,
           a.customer_code         as 客户代码,
           a.customer_name         as 客户名称,
           a.mes_order_create_time as 开单日期,
           a.gmt_modified          as 修改时间,
           b.sn                    as 序号,
           b.process_name          as 工序名称,
           b.remark                as 工序备注,
           b.producting            as 本工序是否生产,
           b.out                   as 是否外协,
           b.bp                    as 本工序是否BP,
           b.gmt_create            as 工序创建时间,
           b.gmt_modified          as 工序修改时间,
           b.latest_start_time     as 最晚开始时间,
           dym.name                as 打印面

    from mes_batch_order a
             join mes_bo_process b on a.id = b.bo_id
             left join sys_dict mest on mest.value = a.mes_order_type and mest.type = 'MES_ORDER_TYPE'
             left join sys_dict dym on dym.id = b.printed_surface
        and dym.type = 'PRINTED_SURFACE'


------------------------------------------------------------------------------------------------------


    WHERE (@begingmt_create IS NULL OR a.gmt_create >= @begingmt_create)
      AND (@endgmt_create IS NULL OR a.gmt_create <= @endgmt_create)
      AND (@BoStatus IS NULL OR a.status in (SELECT value FROM STRING_SPLIT(@BoStatus, ',')))
      AND (@item_code IS NULL OR a.item_code = @item_code)
      AND (@khdm IS NULL OR a.customer_code = @khdm)
      and (@team IS NULL OR a.team = @team)
    order by a.gmt_create desc


    OFFSET @Offset ROWS FETCH NEXT @PageSize ROWS ONLY;

    SELECT @TotalCount = COUNT(1)

    ---------------------------------------------------------------------

    from mes_batch_order a
              join mes_bo_process b on a.id = b.bo_id
             left join sys_dict mest on mest.value = a.mes_order_type and mest.type = 'MES_ORDER_TYPE'
             left join sys_dict dym on dym.id = b.printed_surface
        and dym.type = 'PRINTED_SURFACE'
    -------------------------------------------

    WHERE (@begingmt_create IS NULL OR a.gmt_create >= @begingmt_create)
      AND (@endgmt_create IS NULL OR a.gmt_create <= @endgmt_create)
      AND (@BoStatus IS NULL OR a.status in (SELECT value FROM STRING_SPLIT(@BoStatus, ',')))
      AND (@item_code IS NULL OR a.item_code = @item_code)
      AND (@khdm IS NULL OR a.customer_code = @khdm)
      and (@team IS NULL OR a.team = @team)

END